import LoginStore from '../../pages/login/store.js';
import { reqHeader, isAuthorization } from '../../utils/util.js';
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    data: {
      type: Object,
      value: {},
      observer: function (newVal, oldVal, changedPath) {
        this.setData({
          propsData: newVal
        })
      }
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    popShow:false,
    popStyle: {
      cls: 'hChange'
    },
    popParams:{},
    propsData: {}
  },

  /**
   * 组件的方法列表
   */
  methods: {
    commentsHandler: function (e) {
      if (!isAuthorization(e)) {
        return;
      }
      LoginStore.validateLogin(() => {
        let userAccountInfo = LoginStore.userInfo;
        let avatar = "https://img.500px.me/default_tx.png!a1";
        if (userAccountInfo.avatar.a1) {
          avatar = userAccountInfo.avatar.a1;
        }
        this.setData({
          popShow: true,
          popParams: {
            userAvatar: avatar,
            id: this.data.propsData.id,
            uploaderId: this.data.propsData.uploaderId
          }
        });
      })
    },
    closePop: function (e) {
      let propsData = this.data.propsData;
      propsData.count = e.detail.curCommentCount;
      setTimeout(() => {
        this.setData({
          popShow: false,
          propsData: propsData
        })
      }, 202);

    },
    addAtPeople:function(detail,callback){
      let commentCmp = this.selectComponent('#comments');
      commentCmp.addAtPeople(detail, callback)
    }
  }
})
